#pragma once

// Copyright (c) 2010 Manuel Peinado Gallego <manuel.peinado@gmail.com>
// Distributed under the MIT license

// AABB.h : interface of the AABB class
//


#include <alg3d/alg3d.h>
class Ray;
class Quad;

class AABB
{
public:
    // No initialization (typically used in conjunction with "fromCorners")
    AABB();

    // Inititalization from center and dimensions
    AABB(const gx::Vec3 & d, const gx::Vec3 & c);

    // Inititalization from two corners
    AABB& fromCorners(const gx::Vec3& minCorner, const gx::Vec3& maxCorner);
    void getCorners(gx::Vec3& minCorner, gx::Vec3& maxCorner) const;

    void combine(const AABB& other);
    
    gx::Vec3 center;
    gx::Vec3 dims;

    bool rayIntersection(const Ray & ray, double & dist2) const;
};

void getAllAabbFaces(Quad dest[6]);